//
//  YCTabBarController.swift
//  YCSwiftTest
//
//  Created by Billy on 2024/9/24.
//

import UIKit

class YCTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .white
        setValue(YCTabBar(), forKeyPath: "tabBar")
        tabBar.barTintColor = UIColor.white

        addChild("糗事", "icon_main", "icon_main_active", YCHomeViewController.self)
        addChild("动态", "main_tab_qbfriends", "main_tab_qbfriends_active", YCDynamicViewController.self)
        addChild("直播", "main_tab_live", "main_tab_live_active", YCLiveViewController.self)
    }
    
    func addChild(_ title: String, _ image: String, _ selectImage: String, _ type: UIViewController.Type) {
        
        let vc = YCBaseNavigationController(rootViewController: type.init())
        vc.title = title
        vc.tabBarItem.image = UIImage(named: image)
        vc.tabBarItem.selectedImage = UIImage(named: selectImage)
        
        vc.tabBarItem.setTitleTextAttributes([
            NSAttributedString.Key.foregroundColor: UIColor.black
        ], for: .selected)
        addChild(vc)
    }

}
